package com.cskaoyan.day9;

public class AnimalTest {
    public static void main(String[] args) {
        Animal cat = new Cat("啊咪", 2, "棕色");
        Animal dog = new Dog("大黄", 1, "雄");
        System.out.println(cat.introduce());
        cat.shout();
        cat.play();
        System.out.println(dog.introduce());
        dog.shout();
        dog.play();
    }
}

abstract class Animal {
    String name;
    int age;

    public Animal() {
    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public abstract void shout();

    public abstract void play();

    public String introduce() {
        return "我是" + name + ",今年" + age + "岁";
    }
}

class Cat extends Animal {

    private String color;

    public Cat() {
    }

    public Cat(String name, int age, String color) {
        super(name, age);
        this.color = color;
    }

    public Cat(String color) {
        this.color = color;
    }

    @Override
    public void shout() {
        System.out.println("喵~~~~~");
    }

    @Override
    public void play() {
        System.out.println("天黑请闭眼，小猫咪请睁眼，今天你要抓捕的对象是？");
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }
}

class Dog extends Animal {

    public String gender;

    public Dog() {
    }

    public Dog(String name, int age, String gender) {
        super(name, age);
        this.gender = gender;
    }

    @Override
    public void shout() {
        System.out.println("汪..汪汪汪!");
    }

    @Override
    public void play() {
        System.out.println("主人出门了，我要看大门。");
    }
}
